10 'PROGRAM FOR THE TRS-80 MC-10
20 'J.MCCLELLAN1964@GMAIL.COM
30 'PORTIONS BY ROBERT SIEG
40 'SAMPLE GFX BY PAUL SHOEMAKER
50 'V2.02.21
60 'KBD=PEEK(17023):HL=PEEK(2):PRINT (KB AND HL):GOTO 60
70 GOSUB 1310
80 CLS0:CLEAR 1200:ON ERROR GOTO 1120
90 X=32:Y=16:C=1:S=1:DM=-1:V$="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789":DIM SC$(15),TBL(26),CO(50)
100 CR$=CHR$(127):ER$=STRING$(3,128)::X$=CHR$(126):PA=1:VER$="2.02"
110 FOR I=1 TO 8:READ C$(I):NEXT I:FOR I=1 TO 26:READ TBL(I):NEXT I
120 OPEN"I",#1,"ALPHABET.DAT":INPUT#1,AL$(1),AL$(2),AL$(3):CLOSE#1:GOSUB 380
130 LOAD* CO,"COORDS.DAT"
140 GOSUB 690:IF DM=-1 THEN SET(X,Y,C) ELSE RESET(X,Y)
150 KBD=PEEK(17023):HL=PEEK(2)
160 IF (KBD AND HL)=83 AND X<63 THEN X=X+1
170 IF (KBD AND HL)=65 AND X>0 THEN X=X-1
180 IF (KBD AND HL)=87 AND Y>0 THEN Y=Y-1
190 IF (KBD AND HL)=90 AND Y<29 THEN Y=Y+1
200 IF (KBD AND HL)=67 THEN C=C+1:IF C=9 THEN C=1
210 IF (KBD AND HL)=27 THEN GOSUB 420
220 IF (KBD AND HL)=80 AND Y>0 AND X<63 THEN X=X+1:Y=Y-1
230 IF (KBD AND HL)=79 AND Y>0 AND X<>0 THEN X=X-1:Y=Y-1
240 IF (KBD AND HL)=76 AND X<63 AND Y<29 THEN X=X+1:Y=Y+1
250 IF (KBD AND HL)=75 AND Y<29 AND X>0 THEN X=X-1:Y=Y+1
260 IF (KBD AND HL)=50 THEN GOSUB 870
270 IF (KBD AND HL)=72 THEN GOSUB 480
280 IF (KBD AND HL)=45 THEN GOSUB 1490
290 IF (KBD AND HL)=32 THEN DM=NOT(DM)
300 IF (KBD AND HL)=9 THEN GOSUB 780
310 IF (KBD AND HL)=60 THEN GOSUB 1150
320 IF (KBD AND HL)=51 THEN GOSUB 1340
330 IF (KBD AND HL)=48 THEN GOSUB 1560
340 IF (KBD AND HL)=28 THEN REC=-1:GOSUB 870
350 IF (KBD AND HL)=8 THEN GOSUB 1800
360 IF (KBD AND HL)=49 THEN GOSUB 1940
370 GOSUB 380:GOTO 140
380 PRINT@480,"MODE:";
390 IF DM=0 THEN PRINT"ERASE"; ELSE PRINT"DRAW ";
400 PRINT" X:";X;" Y:";Y;"CLR:   ";:PRINT@508,C$(C);
410 RETURN
420 PCOPY 0 TO 1
430 PRINT@163,"ERASE ENTIRE SCREEN? (Y/N)";
440 I$=INKEY$:IF I$="" THEN 440
450 IF I$="Y" THEN CLS0:RETURN
460 IF I$="N" THEN PCOPY 1 TO 0:RETURN
470 GOTO 440
480 PCOPY 0 TO 1
490 CLS:PRINT@5, "--- MCDRAW ";VER$;" HELP ---"
500 PRINT"w: CURSOR UP","z: CURSOR DOWN"
510 PRINT"a: CURSOR RIGHT","s: CURSOR LEFT"
520 PRINT"o: UP/LEFT","p: UP/RIGHT"
530 PRINT"l: DOWN/RIGHT","k: DOWN/LEFT"
540 PRINT"c: COLOR SEL","-: VIEW GRID"
550 PRINT"0: CURSOR 0,0"
560 PRINT"<SPACEBAR>: TOGGLE DRAW/UNDRAW"
570 PRINT"<CTRL>+A: TYPE ALPHABET"
580 PRINT"<CTRL>+B: SAVE AS BASIC PROGRAM"
590 PRINT"<CTRL>+C: PLOT A CIRCLE"
600 PRINT"<CTRL>+E: ERASE ENTIRE SCREEN"
610 PRINT"<CTRL>+L: LOAD SCREEN FROM FILE"
620 PRINT"<CTRL>+R: PLOT RECTANGLE"
630 PRINT"<CTRL>+S: SAVE SCREEN TO FILE"
640 PRINT"<CTRL>+X: EXCHANGE COLORS";
650 'PRINT@482,"<SPACE> TO RETURN TO MCDRAW";
660 I$=INKEY$
670 IF I$=" " THEN PCOPY 1 TO 0:RETURN
680 GOTO 660
690 SET(X,Y,C)
700 FOR I=1 TO 25
710 KBD=PEEK(17023) AND PEEK(2):IF KBD<>0 THEN RETURN
720 NEXT I
730 RESET(X,Y)
740 FOR I=1 TO 25
750 KBD=PEEK(17023) AND PEEK(2):IF KBD<>0 THEN RETURN
760 NEXT I
770 GOTO 690
780 PCOPY 0 TO 1
790 GOSUB 2160
800 IF F$="" THEN PCOPY1TO0:RETURN
810 SAVEM F$,16384,16863
820 PRINT@168,"SCREEN SAVED!";
830 PRINT@200,"PRESS <SPACE>";
840 I$=INKEY$:IF I$="" THEN GOTO 840
850 IF I$=" " THEN PCOPY 1 TO 0:RETURN
860 GOTO 840
870 PRINT@480,"  SHAPE SIZE? (1-9) 0 TO EXIT  ";
880 I$=INKEY$:IF I$="" THEN GOTO 880
890 IF I$="0" THEN RETURN
900 R=VAL(I$)
910 IF R=0 THEN GOTO 880
920 IF Y-R<0 OR Y+R>29 OR X-R<0 OR X+R>63 THEN GOSUB 1220:RETURN
930 IF REC=-1 THEN GOSUB 1580:RETURN
940 XC=X:YC=Y
950 X1=R:Y1=0:RADIUS=1-X1
960 FOR I=1 TO R
970 IF X1<Y1-1 THEN RETURN
980 SET (X1+XC,Y1+YC,C)
990 SET (Y1+XC,X1+YC,C)
1000 SET (-X1+XC,Y1+YC,C)
1010 SET (-Y1+XC,X1+YC,C)
1020 SET (-X1+XC,-Y1+YC,C)
1030 SET (-Y1+XC,-X1+YC,C)
1040 SET (X1+XC,-Y1+YC,C)
1050 SET (Y1+XC,-X1+YC,C)
1060 Y1=Y1+1
1070 IF RADIUS<0 THEN RADIUS=RADIUS+2*Y1+1:GOTO 1100
1080 X1=X1-1
1090 RADIUS=RADIUS+2*(Y1-X1)+1
1100 NEXT I
1110 RETURN
1120 IF ERRN=8 THEN GOSUB 1220:GOTO 140
1130 IF ERRN=40 THEN GOSUB 1260:PCOPY 1 TO 0:GOTO 140
1140 '**** IGNORE
1150 PCOPY 0 TO 1
1160 CLS
1170 PRINT"ENTER FILENAME TO LOAD"
1180 PRINT"(ENTER) CANCELS LOAD"
1190 LINEINPUT"-->";F$
1200 IF F$="" THEN PCOPY 1 TO 0:RETURN
1210 LOADM F$:RETURN
1220 'OUT OF BOUNDS CIRCLE TRAP
1230 PRINT@480," TOO LARGE TO FIT. PRESS SPACE.";:SOUND 1,5
1240 I$=INKEY$:IF I$<>" " THEN GOTO 1240
1250 RETURN
1260 PRINT"FILE NOT FOUND."
1270 PRINT"PRESS SPACE."
1280 I$=INKEY$:IF I$<>" " THEN GOTO 1280
1290 RETURN
1300 DATA"GRN","YEL","BLU","RED","WHT","GRY","MAG","ORG"
1310 MCX$=CHR$(PEEK(65498))+CHR$(PEEK(65499))
1320 IF MCX$<>"EX" THEN PRINT "THIS PROGRAM REQUIRES":PRINT"THE MCX EXPANSION.":END
1330 RETURN
1340 GOSUB 2160:IF F$="" THEN PCOPY1TO0:RETURN
1350 L=0:PRINT@480,"GENERATING BASIC PROGRAM...    ";
1360 FOR I=16384 TO 16863 STEP 32
1370 FOR J=I TO I+31
1380 SC$(L)=SC$(L)+CHR$(PEEK(J))
1390 NEXT J
1400 L=L+1
1410 NEXT I
1420 LN=100:OPEN"O",#1,F$+".BAS"
1430 FOR I=0 TO 14
1440 SC$(I)=STR$(LN)+"PRINT"+CHR$(34)+SC$(I)+CHR$(34)+";"
1450 PRINT#1, SC$(I):SC$(I)=""
1460 LN=LN+10:NEXT I
1470 CLOSE#1
1480 PCOPY 1 TO 0:RETURN
1490 PCOPY 0TO1:FORA=16384TO16863
1500 IF (A AND 32) THEN IF(A/2)>INT(A/2)THENIFPEEK@(A)=128THENPOKE@A,207
1510 IF (A AND 32)<>32 THENIF(A/2)=INT(A/2)THENIFPEEK@(A)=128THENPOKE@A,207
1520 NEXTA
1530 PRINT@480,"    PRESS <SPACE> TO RETURN    ";
1540 I$=INKEY$:IF I$<>" " THEN GOTO 1540
1550 PCOPY1 TO 0:RETURN
1560 IF DM=-1 THEN SET(X,Y,C) ELSE RESET(X,Y)
1570 X=0:Y=0:RETURN
1580 'draw rectangle routine
1590 X1=(X-R):X2=(X+R)
1600 Y1=(Y-R):Y2=(Y+R)
1610 FOR I=X1 TO X2
1620 SET(I,Y-R,C)
1630 SET(I,Y+R,C)
1640 NEXT I
1650 FOR I=Y1 TO Y2
1660 SET(X1,I,C)
1670 SET(X1+R*2,I,C)
1680 NEXT I:REC=0
1690 PRINT@480,"        FILL RECTANGLE?        ";
1700 I$=INKEY$:IF I$<>"N" AND I$<>"Y" THEN GOTO 1700
1710 IF I$="N" THEN RETURN
1720 FOR I=Y1 TO Y2
1730 FOR J=X1 TO X2
1740 SET(J,I,C)
1750 NEXT J,I
1760 RETURN
1770 DATA 1,4,7,10,13,16,19,22,25,28
1780 DATA 33,36,39,42,45,48,51,54,57,60
1790 DATA 65,68,71,74,77,80
1800 POKE17023,0:PRINT@480,"  ALPHATYPE - PRESS @ TO EXIT  ";:PCOPY0TO1
1810 PRINT@CO(PA),CR$;
1820 I$=INKEY$:IF I$="" THEN GOTO 1820
1830 M=ASC(I$)
1840 IF M=64 THEN PCOPY1TO0:RETURN
1850 IF M=45 THEN PRINT@CO(PA),ER$;:PRINT@CO(PA)+32,ER$;:PRINT@CO(PA)+64,ER$;:PCOPY0TO1
1860 IF M=9 AND PA<>50 THEN PA=PA+1:PCOPY1TO0:GOTO 1810
1870 IF M=8 AND PA<>1 THEN PA=PA-1:PCOPY1TO0:GOTO 1810
1880 L=INSTR(LEFT$(V$,26),I$):IFL=0 THEN GOTO 1810
1890 PCOPY1TO0
1900 PRINT@CO(PA),MID$(AL$(1),TBL(L),3);
1910 PRINT@CO(PA)+32,MID$(AL$(2),TBL(L),3);
1920 PRINT@CO(PA)+64,MID$(AL$(3),TBL(L),3);
1930 PCOPY0TO1:GOTO1810
1940 'exchange colors routine
1950 PCOPY0TO1:CLS0:R=0
1960 PRINT@480,"CHOOSE COLOR TO EXCHANGE FROM..";:CL=32:GOSUB 2040:GOSUB2080:C1=CX:IF R=-1 THEN PCOPY 1 TO 0:RETURN
1970 PRINT@480,"CHOOSE COLOR TO EXCHANGE TO....";:CL=32:GOSUB2040:GOSUB2080:C2=CX:IF R=-1 THEN PCOPY 1 TO 0:RETURN
1980 PCOPY 1 TO 0:PRINT@480,"      EXCHANGING COLORS...     ";
1990 FOR Y2=0 TO 29
2000 FOR X2=0 TO 63
2010 IF POINT(X2,Y2)=C1 THEN SET(X2,Y2,C2)
2020 NEXT X2,Y2
2030 RETURN
2040 CX=1:FOR XX=0 TO 31 STEP 4
2050 SET(XX,0,CX):SET(XX,1,CX)
2060 SET(XX+1,0,CX):SET(XX+1,1,CX)
2070 CX=CX+1:NEXT XX:RETURN
2080 CX=1
2090 PRINT@CL,X$;
2100 I$=INKEY$:IF I$="" THEN GOTO 2100
2110 IF I$="S" AND CX<>8 THEN PRINT@CL,CHR$(128);:CL=CL+2:CX=CX+1
2120 IF I$="A" AND CX<>1 THEN PRINT@CL,CHR$(128);:CL=CL-2:CX=CX-1
2130 IF I$=CHR$(13) THEN PRINT@CL,CHR$(128);:RETURN
2140 IF I$="0" THEN R=-1:RETURN
2150 GOTO 2090
2160 'get filename for saves
2170 PCOPY0TO1:CLS:F$=""
2180 PRINT"ENTER FILENAME TO SAVE TO":PRINT"<ENTER> CANCELS":LINEINPUT"-->";F$
2190 IF F$="" THEN RETURN
2200 FOR I=1 TO LEN(F$)
2210 M$=MID$(F$,I,1)
2220 V=INSTR(V$,M$)
2230 IF V=0 THEN PRINT"INVALID FILENAME.":GOTO 2180
2240 NEXT I:PCOPY 1 TO 0:RETURN
